/*
 * Copyright 2003-2007 (c) Live Media Pty Ltd. <argot@einet.com.au> 
 *
 * This software is licensed under the Argot Public License 
 * which may be found in the file LICENSE distributed 
 * with this software.
 *
 * More information about this license can be found at
 * http://www.einet.com.au/License
 * 
 * The Developer of this software is Live Media Pty Ltd,
 * PO Box 4591, Melbourne 3001, Australia.  The license is subject 
 * to the law of Victoria, Australia, and subject to exclusive 
 * jurisdiction of the Victorian courts.
 */

package com.colony.channel.types;

import java.io.IOException;
import java.io.InputStream;

import com.argot.TypeException;
import com.argot.TypeOutputStream;
import com.argot.TypeWriter;
import com.colony.channel.ChannelClient;
import com.colony.channel.ChannelIdentifier;

// This is the outgoing version.
// In this version an input stream is being sent to
// the server.  Pass the inputstream to the server
// and then write the identifier to the output stream.

public class ChannelInputStreamClientWriter
implements TypeWriter
{
	ChannelClient _client;
	
	public ChannelInputStreamClientWriter( ChannelClient client )
	{
		_client = client;
	}

	public void write( TypeOutputStream out, Object o ) 
	throws TypeException, IOException
	{
		InputStream in = (InputStream) o;
		ChannelIdentifier cid = _client.connectSendStream(in,null);
		out.writeObject(ChannelIdentifier.TYPENAME, cid );
	}
}